package mofei.concurrent.task;

/**
 * @author mofei@staff.weibo.com
 * @date 2019/2/22 2:12 PM
 */
public class BlockedTask1 implements Runnable {
    public static Object mutex1=new Object();
    public static Object mutex2=new Object();


    @Override
    public void run() {
        synchronized(mutex1){
            System.out.println("获取mutex1的锁，现在进入休眠");
            try {
                Thread.sleep(5*1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("mutex1,结束休眠");
            synchronized (mutex2){
                System.out.println("成功获取mutex2的锁");
            }
        }
    }
}
